<!--
Copyright 2008-2010 Mark Logic Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<xs:schema 
	xmlns:xs='http://www.w3.org/2001/XMLSchema' 
	xmlns='http://marklogic.com/toolkit/word/author/config' 
	targetNamespace = 'http://marklogic.com/toolkit/word/author/config'
	elementFormDefault='qualified'>

	<xs:simpleType name="icontype">
           <xs:restriction base="xs:string">
             <xs:enumeration value="word"/>
             <xs:enumeration value="image"/>
             <xs:enumeration value="chart"/>
           </xs:restriction>
        </xs:simpleType>

	<!-- definition of simple elements -->
	<xs:element name="display-label" type="xs:string"/>
        <xs:element name="document-uri" type="xs:string"/>
        <xs:element name="icon" type="icontype"/>

        <xs:element name="control-alias" type="xs:string"/>
	
	<xs:element name="value" type="xs:string"/>

	<xs:element name="title" type="xs:string"/>
        <xs:element name="placeholdertext" type="xs:string"/>
	<xs:element name="metatemplate" type="xs:token"/>
	<xs:element name="newline" type="xs:string"/>
	<xs:element name="text" type="xs:string"/>

	<!-- definition of complex elements -->
  	<xs:element name="entry">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="text"/>
              <xs:element ref="value"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

  	<xs:element name="richtext">
	  <xs:complexType>
	    <xs:all>
               <xs:element ref="title"/>
               <xs:element ref="metatemplate"/>
               <xs:element ref="newline" minOccurs="0" />
               <xs:element ref="placeholdertext" minOccurs="0"/>
               <xs:element ref="component" minOccurs="0"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

      	<xs:element name="image">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="title"/>
              <xs:element ref="metatemplate"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

    	<xs:element name="calendar">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="title"/>
              <xs:element ref="placeholdertext" minOccurs="0"/>
              <xs:element ref="metatemplate"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

    	<xs:element name="combo">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="title"/>
              <xs:element ref="placeholdertext" minOccurs="0"/>
	      <xs:element ref="metatemplate"/>
	      <xs:element ref="entry" maxOccurs="unbounded"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

    	<xs:element name="dropdown">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="title"/>
              <xs:element ref="placeholdertext" minOccurs="0"/>
	      <xs:element ref="metatemplate"/>
	      <xs:element ref="entry" maxOccurs="unbounded"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

        <xs:element name="component">
	  <xs:complexType>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
		    <xs:element ref="richtext"/>
		    <xs:element ref="image"/>
                    <xs:element ref="calendar"/>
                    <xs:element ref="dropdown"/>
		    <xs:element ref="combo"/>
            </xs:choice>
          </xs:complexType>
        </xs:element>

  	<xs:element name="section">
	  <xs:complexType>
            <xs:sequence>
              <xs:element ref="richtext" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

  	<xs:element name="inline">
	  <xs:complexType>
	    <xs:choice minOccurs="0" maxOccurs="unbounded">
	      <xs:element ref="richtext"/>
              <xs:element ref="image"/>
              <xs:element ref="calendar"/>
              <xs:element ref="dropdown"/>
              <xs:element ref="combo"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

	<xs:element name="boilerplate">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="display-label"/>
              <xs:element ref="document-uri"/>
	      <xs:element ref="icon"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

    	<xs:element name="template">
	  <xs:complexType>
	    <xs:sequence>
	      <xs:any namespace="##other" processContents="skip"/>
	    </xs:sequence>
	    <xs:attribute name="id" type="xs:token" use="required"/>
	  </xs:complexType>
        </xs:element>

  	<xs:element name="searchfilter">
	  <xs:complexType>
	    <xs:all>
              <xs:element ref="display-label"/>
              <xs:element ref="control-alias"/>
            </xs:all>
          </xs:complexType>
        </xs:element>

      	<xs:element name="element">
	  <xs:complexType>
              <xs:attribute name="namespace" type="xs:anyURI" use="required"/>
	      <xs:attribute name="qname" type="xs:string" use="required"/>
	  </xs:complexType>
        </xs:element>

    	<xs:element name="comparefilter">
	  <xs:complexType>
            <xs:all>
              <xs:element ref="element"/>
              <xs:element ref="value"/>
              <xs:element ref="display-label"/>
            </xs:all>
          </xs:complexType>
        </xs:element>


        <xs:element name="boilerplates">
          <xs:annotation>
            <xs:documentation>
		     List of Word docs that can be inserted whole into the Active Document.
		     display-label: what the user will see in the app
		     document-uri: the doc noted by its fullpath within the Server
		     icon:  the image to be used in the app to indicate what type of doc it is
             </xs:documentation>
             <xs:appinfo>
             </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
	    <xs:sequence>
              <xs:element ref="boilerplate" maxOccurs="unbounded"/>
	    </xs:sequence>
          </xs:complexType>
        </xs:element>
  
	<xs:element name="templates">
          <xs:annotation>
            <xs:documentation>
		     Metadata forms to be associated with Content Controls. 
		     @id maps to the metatemplate element value in controls.xml.
            </xs:documentation>
            <xs:appinfo>
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
	     <xs:sequence>
               <xs:element ref="template" maxOccurs="unbounded">
	     </xs:sequence>
          </xs:complexType>
        </xs:element>

	<xs:element name="searchfilters">
          <xs:annotation>
            <xs:documentation>
		    Filters to be applied to search where 
		    controlalias is the value searched on in the structure and
		    diplay-label is the option displayed to the user in the app
            </xs:documentation>
            <xs:appinfo>
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
	     <xs:sequence>
               <xs:element ref="searchfilter" maxOccurs="unbounded">
	     </xs:sequence>
          </xs:complexType>
        </xs:element>

  	<xs:element name="comparefilters">
          <xs:annotation>
            <xs:documentation>
		    Filters to be applied to metadata search where
		    element provides the element for an element-value-query 
		    value is the text value to search on
		    diplay-label is the option displayed to the user in the app
            </xs:documentation>
            <xs:appinfo>
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
	     <xs:sequence>
               <xs:element ref="comparefilter" maxOccurs="unbounded">
	     </xs:sequence>
          </xs:complexType>
        </xs:element>

    	<xs:element name="controls">
          <xs:annotation>
            <xs:documentation>
		    The Content Controls to be displayed in the application.  
		    Required javascript for interaction with Active Document also generated.
            </xs:documentation>
            <xs:appinfo>
            </xs:appinfo>
          </xs:annotation>
          <xs:complexType>
	     <xs:sequence>
               <xs:element ref="section">
               <xs:element ref="inline">
	     </xs:sequence>
          </xs:complexType>
        </xs:element>
</xs:schema>

